﻿<%@ Page Title="" Language="C#" MasterPageFile="ReconSite.Master" AutoEventWireup="true" CodeBehind="RoleMaster.aspx.cs" Inherits="Recon.Portal.WebUI.RoleMaster" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleHolder" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyHolder" runat="server">

    <div class="formDiv" style="width: 45%">
        <h2 class="formTitle">Role Master</h2>
        <h1 class="formError" style="text-align: right; font-size: smaller; color: #CC2900;">Fields marked with * are mandatory</h1>
        <table cellspacing="1" cellpadding="1" border="0" width="100%">

           <%-- <tr>
                <td align="right">Option<span class="required">*</span>
                </td>
                <td colspan="3">
                    <asp:RadioButtonList ID="rbOption" runat="server" RepeatDirection="Horizontal"
                        RepeatLayout="Flow" AutoPostBack="True"
                        OnSelectedIndexChanged="rbOption_SelectedIndexChanged">
                        <asp:ListItem Value="1" Selected="True">Add</asp:ListItem>
                        <asp:ListItem Value="2">Modify</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>--%>
            <tr>
                <td align="right">Role ID<span class="required">*</span>
                </td>
                <td colspan="3">
                    <input id="txtRoleID" style="width: 125px" type="text" runat="server"
                        enableviewstate="true" maxlength="10" />

                    <%--<asp:Button ID="bntbrowse" runat="server" Text="..." Width="25px" OnClick="bntbrowse_Click" CausesValidation="False" />
                    <asp:Button ID="bntgetdetails" runat="server" Text="Get Details" OnClick="bntgetdetails_Click" CausesValidation="False" OnClientClick="javascript:return SelectUser();" />--%>
                    <asp:RequiredFieldValidator ID="reqRoleID" runat="server"
                        ErrorMessage="Role ID is Mandatory" CssClass="formError"
                        ControlToValidate="txtRoleID" InitialValue=""
                        SetFocusOnError="True"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="regRoleID" runat="server"
                        ControlToValidate="txtRoleID" CssClass="formError"
                        ErrorMessage="Invalid Role ID" ValidationExpression="^[a-zA-Z0-9]+$"
                        SetFocusOnError="True"></asp:RegularExpressionValidator>
                </td>
            </tr>

            <tr>
                <td align="right">Role Description<span class="required">*</span>
                </td>
                <td colspan="3">
                    <asp:TextBox ID="txtRoleDesc" runat="server" MaxLength="50"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="reqtxtRoleDesc" runat="server" ControlToValidate="txtRoleDesc"
                        ErrorMessage="Role Description is mandatory" SetFocusOnError="True" CssClass="formError"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="regtxtRoleDesc" runat="server" ControlToValidate="txtRoleDesc"
                        EnableViewState="False" ErrorMessage="Invalid Role Description" SetFocusOnError="True"
                        ValidationExpression="^[A-Za-z0-9' '.]{0,50}$" CssClass="formError"></asp:RegularExpressionValidator>
                </td>
            </tr>

            <tr>
                <td align="right">Role Type<span class="required">*</span>
                </td>
                <td colspan="3">
                    <asp:DropDownList ID="ddlRoleType" runat="server" AutoPostBack="False">
                        <asp:ListItem Value="0">Select Role Type</asp:ListItem>
                        <asp:ListItem Value="S">System</asp:ListItem>
                        <asp:ListItem Value="C">Customer</asp:ListItem>
                        <asp:ListItem Value="R">Remitter</asp:ListItem>
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="reqRoleType" runat="server"
                        ErrorMessage="Role Type is Mandatory" CssClass="formError"
                        ControlToValidate="ddlRoleType" InitialValue="0"
                        SetFocusOnError="True"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td align="right"></td>
                <td colspan="3">
                    <asp:CheckBox ID="chkEnable" runat="server" Text="Enable" Checked="True" />
                </td>
            </tr>

            <tr>
                <td align="right"></td>
                <td colspan="3">
                    <asp:Button ID="btnSubmit" runat="server" Text="Add" OnClick="btnSubmit_Click" />
                    <asp:Button ID="btnCancel" runat="server" Text="Reset" CausesValidation="False" OnClick="btnCancel_Click" />
                </td>
            </tr>
        </table>
         <div style="height:140px; width:100%; overflow:auto;">
                <asp:GridView ID="gvCustomer" runat="server" AllowPaging="false" 
                        AutoGenerateColumns="False" Width="100%"
                        HeaderStyle-BackColor="silver" HeaderStyle-ForeColor="#6f788f" 
                            HeaderStyle-Font-Bold="false" OnRowDeleting="gvCustAccount_RowDeleting">
                    <EmptyDataTemplate>
                        <asp:Label ID="lblNoRows" runat="server" Text="No records found for customer account detail." />
                    </EmptyDataTemplate>
                    <Columns>
                        <asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:LinkButton  ID = "lnkSelect" runat="server"  Text = "Select"  CausesValidation="false" CommandName="Select"></asp:LinkButton>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Role ID" ShowHeader="False" ItemStyle-HorizontalAlign="Center">
                           <ItemTemplate>
                               <asp:Label ID="lblRoleID" runat="server" Text='<%# Eval("RoleID") %>'></asp:Label>
                           </ItemTemplate>
                       </asp:TemplateField>
                        <asp:TemplateField HeaderText="Role Description" ItemStyle-HorizontalAlign="Center">                                   
                            <ItemTemplate>
                                <asp:Label ID="lblRoleDescription" runat="server" Text='<%# Eval("RoleDescription") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="Role Type" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblRoleType" runat="server" Text='<%# Eval("RoleType") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Enabled?" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblIsEnabled" runat="server"  Text='<%# Eval("IsEnabled") %>'></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ItemStyle-HorizontalAlign="Center"/>
                    </Columns>
                </asp:GridView>
                </div>
        <asp:UpdatePanel ID="upUnmatchedLists" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <div id="pnlMatchList" runat="server" class="pnlMatchList">
                    <span style="azimuth: center;">
                        <div class="formDiv" runat="server">
                            <center>
                                <asp:Label ID="lblMessage" runat="server" CssClass="lable" />
                            </center>
                        </div>
                    </span>
                    <div class="formDiv" style="width: 30%;">
                        <center>
                            <asp:Button ID="btnok" runat="server" Text="OK" OnClick="btnok_Click" CausesValidation="False" />
                        </center>
                    </div>
                </div>
                <div style="display: none">
                    <asp:Button ID="btnManualPopup" runat="server" />
                </div>
                <ajax:ModalPopupExtender ID="btnClickPopup" runat="server" PopupControlID="pnlMatchList"
                    TargetControlID="btnManualPopup" BackgroundCssClass="modalBackground" RepositionMode="RepositionOnWindowScroll" OkControlID="btnok">
                </ajax:ModalPopupExtender>
            </ContentTemplate>
        </asp:UpdatePanel>


    </div>


    <script type="text/javascript">
        $(function () {
            
            $("[id*=lnkSelect]").click(function () {
                var tr = $(this).closest('tr');
                var RoleID = $(tr).find('span[id*="lblRoleID"]').text();
                var RoleDescription = $(tr).find('span[id*="lblRoleDescription"]').text();
                var RoleType = $(tr).find('span[id*="lblRoleType"]').text();
                var isEnable = $(tr).find('span[id*="lblIsEnabled"]').text();

                $("#<%= txtRoleID.ClientID %>").val(RoleID).text();
                       $("#<%= txtRoleDesc.ClientID %>").val(RoleDescription).text();
                       $("#<%= ddlRoleType.ClientID %>").val(RoleType).text();

                var btntext = "Modify";
                $("#<%= btnSubmit.ClientID %>").val(btntext).text();

                       if (isEnable.toString() == "True") {
                           $("#<%= chkEnable.ClientID %>").prop('checked', true);
                 }
                 else { $("#<%= chkEnable.ClientID %>").prop('checked', false); }
                       return false;
                   });
         });


        function SelectUser() {
            var Username = document.getElementById('<%=txtRoleID.ClientID %>').value;
             if (Username == '') {
                 alert("Role ID is Mandatory");
                 return false;
             }

             return true;
         }
    </script>
</asp:Content>
